import logging
import requests

logger = logging.getLogger(__name__)


def 揽收预警上传(filepath, date_hour):
    url = 'http://192.168.16.240:8001/api/Warning/LogisticsCollecting/ImportData'
    files = {'file': (f'揽收预警{date_hour}.xlsx', open(filepath, 'rb'))}
    res = requests.post(url, files=files)
    if res.status_code == 200 and 'false' not in res.text:
        print('订单上传成功')
        print(res.text)
        logger.info(res.text)
        logger.info('订单上传成功')
    else:
        print('订单上传失败')
        print(res)
        logger.info('订单上传失败')
